package com.ykc.demo.AOP;

import com.ykc.proxy.AspectProxy;
import com.ykc.spring.Aspect;

import java.lang.reflect.Method;

//@Aspect(pkg = "com.com.ykc.demo.controller",cls = "Controller")
public class LogAop extends AspectProxy {
    private long begin;

    /**
     * 切入点判断
     */
    @Override
    public boolean intercept(Method method, Object[] params) throws Throwable {
        return method.getName().equals("test");
    }

    @Override
    public void before(Method method, Object[] params) throws Throwable {
        System.out.println("---------- 开始记录日志 ----------");
//        begin = System.currentTimeMillis();
//        System.out.println(begin);
    }

    @Override
    public void after(Method method, Object[] params) throws Throwable {
//        System.out.println(String.format("time: %dms", System.currentTimeMillis() - begin));
        System.out.println("----------- 日志记录结束 -----------");
    }
}
